<template>
  <div class="uploader">
      <el-upload
        action="http://192.168.13.127:8080/GlobalLove/center/identify?name=劳惠敏"
        list-type="picture-card"
        :with-credentials="true"
        name="photo"
        :on-preview="handlePictureCardPreview"
        :on-remove="handleRemove"
        :on-success="handleSuccess"
      >
        <i class="el-icon-plus"></i>
      </el-upload>
      <el-dialog v-model="dialogVisible" size="tiny">
        <img width="100%" :src="dialogImageUrl" alt="">
      </el-dialog>
      <div class="verify_btn">
        <el-button type="primary"><i class="el-icon-upload el-icon--right">确认上传</i></el-button>
        <router-link :to="{name: 'home'}" replace><el-button >跳过</el-button></router-link>
      </div>
      <div class="verify_intro">
        <h4>为什么需要查看身份证信息</h4>
        <p>
          因为通过身份认证的会员诚信度比较高，我们建议您在选择交往对象时优先考虑这类会员
        </p>
      </div>
      <el-dialog
        title="提示"
        :visible.sync="dialogVisible"
        size="tiny"
      >
      <span>上传成功！等待审核</span>
      <span slot="footer" class="dialog-footer">
        <router-link :to="{name:'home'}" replace>
          <el-button type="primary">去首页</el-button>
        </router-link>      
      </span>
      </el-dialog>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        dialogImageUrl: '',
        dialogVisible: false
      };
    },
    methods: {
      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePictureCardPreview(file) {
        this.dialogImageUrl = file.url;
        this.dialogVisible = true;
      },
      handleSuccess(response) {
        if(response.status="SUCCESS") {
            this.dialogVisible = true;
        }
        console.log(response);
      }
    }
  }
</script>

<style scoped>
  .uploader{
    width: 550px;
    margin: 100px auto 50px auto;
    z-index: 2;
  }
  input[type='file'] {
    display: none;
  }
  .verify_btn {
    margin-top: 50px;
    text-align: center;
  }
  .verify_intro {
    border-top: 3px solid #F06079;
    margin-top: 50px;
  }
</style>